package com.mvc.listener;

import java.util.List;

import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import com.mvc.container.SpringContainer;
import com.mvc.utils.XmlUtils;

public class ActionListener implements ServletContextListener {

	@Override
	public void contextDestroyed(ServletContextEvent arg0) {
		System.out.println("==============simple mvc已注销！==============");
	}

	@Override
	public void contextInitialized(ServletContextEvent arg0) {
		ServletContext context = arg0.getServletContext();
		String xmlpath = context.getInitParameter("annotation-mvc");
		String tomcatpath = context.getRealPath("\\");
		try {
			List<SpringContainer> list = XmlUtils.simpleXml(tomcatpath + xmlpath);
			context.setAttribute("simple", list);
		} catch (Exception e) {
			e.printStackTrace();
		}
		System.out.println("==============simple mvc已加载完成！==============");
	}

}
